package com.khaled.protclass.model.feature.physicochemical;

import java.util.HashMap;

import com.khaled.protclass.model.util.UtilAminoAcids;
import com.khaled.protclass.model.util.UtilArray;

public class PhysicoChemical extends UtilAminoAcids
{
	private static PhysicoChemical physicoChemical;

	public static PhysicoChemical getInstance()
	{
		if (physicoChemical == null)
		{
			physicoChemical = new PhysicoChemical();
		}
		return physicoChemical;
	}

	private HashMap<String, Double> Hydrophopicity = null;

	private HashMap<String, Double> Hydrophilicity = null;

	private HashMap<String, Double> Flexibility = null;

	private HashMap<String, Double> Accessibility = null;

	private HashMap<String, Double> Exposed = null;

	private HashMap<String, Double> Turns = null;

	private HashMap<String, Double> Antegenic = null;

	private HashMap<String, Double> Polarity = null;

	private HashMap<String, Double> N_Hydrophopicity = null;

	private HashMap<String, Double> N_Hydrophilicity = null;

	private HashMap<String, Double> N_Flexibility = null;

	private HashMap<String, Double> N_Accessibility = null;

	private HashMap<String, Double> N_Exposed = null;

	private HashMap<String, Double> N_Turns = null;

	private HashMap<String, Double> N_Antegenic = null;

	private HashMap<String, Double> N_Polarity = null;

	public HashMap<String, Double> getHydrophopicity(boolean normalize)
	{
		if (this.Hydrophopicity == null)
		{
			fillHydrophopicity();
		}

		if (!normalize)
		{
			return Hydrophopicity;
		}
		else
		{
			if (N_Hydrophopicity == null)
			{
				N_Hydrophopicity = UtilArray.normalize(this.Hydrophopicity);
			}

			return N_Hydrophopicity;
		}
	}

	public HashMap<String, Double> getHydrophilicity(boolean normalize)
	{
		if (this.Hydrophilicity == null)
		{
			fillHydrophilicity();
		}

		if (!normalize)
		{
			return Hydrophilicity;
		}
		else
		{
			if (N_Hydrophilicity == null)
			{
				N_Hydrophilicity = UtilArray.normalize(this.Hydrophilicity);
			}

			return N_Hydrophilicity;
		}
	}

	public HashMap<String, Double> getFlexibility(boolean normalize)
	{
		if (this.Flexibility == null)
		{
			fillFlexibility();
		}

		if (!normalize)
		{
			return Flexibility;
		}
		else
		{
			if (N_Flexibility == null)
			{
				N_Flexibility = UtilArray.normalize(this.Flexibility);
			}

			return N_Flexibility;
		}
	}

	public HashMap<String, Double> getAccessibility(boolean normalize)
	{
		if (this.Accessibility == null)
		{
			fillAccessibility();
		}

		if (!normalize)
		{
			return Accessibility;
		}
		else
		{
			if (N_Accessibility == null)
			{
				N_Accessibility = UtilArray.normalize(this.Accessibility);
			}

			return N_Accessibility;
		}
	}

	public HashMap<String, Double> getExposed(boolean normalize)
	{
		if (this.Exposed == null)
		{
			fillExposed();
		}

		if (!normalize)
		{
			return Exposed;
		}
		else
		{
			if (N_Exposed == null)
			{
				N_Exposed = UtilArray.normalize(this.Exposed);
			}

			return N_Exposed;
		}
	}

	public HashMap<String, Double> getTurns(boolean normalize)
	{
		if (this.Turns == null)
		{
			fillTurns();
		}

		if (!normalize)
		{
			return Turns;
		}
		else
		{
			if (N_Turns == null)
			{
				N_Turns = UtilArray.normalize(this.Turns);
			}

			return N_Turns;
		}
	}

	public HashMap<String, Double> getAntegenic(boolean normalize)
	{
		if (this.Antegenic == null)
		{
			fillAntegenic();
		}

		if (!normalize)
		{
			return Antegenic;
		}
		else
		{
			if (N_Antegenic == null)
			{
				N_Antegenic = UtilArray.normalize(this.Antegenic);
			}

			return N_Antegenic;
		}
	}

	public HashMap<String, Double> getPolarity(boolean normalize)
	{
		if (this.Polarity == null)
		{
			fillPolarity();
		}

		if (!normalize)
		{
			return Polarity;
		}
		else
		{
			if (N_Polarity == null)
			{
				N_Polarity = UtilArray.normalize(this.Polarity);
			}

			return N_Polarity;
		}
	}

	private void fillPolarity()
	{
		this.Polarity = new HashMap<String, Double>();

		this.Polarity.put(A, new Double(1.08));
		this.Polarity.put(C, new Double(0.733));
		this.Polarity.put(D, new Double(1.266));
		this.Polarity.put(E, new Double(1.085));
		this.Polarity.put(F, new Double(0.685));
		this.Polarity.put(G, new Double(1.104));
		this.Polarity.put(H, new Double(0.906));
		this.Polarity.put(I, new Double(0.583));
		this.Polarity.put(K, new Double(1.026));
		this.Polarity.put(L, new Double(0.789));
		this.Polarity.put(M, new Double(0.812));
		this.Polarity.put(N, new Double(1.197));
		this.Polarity.put(P, new Double(1.412));
		this.Polarity.put(Q, new Double(1.05));
		this.Polarity.put(R, new Double(0.976));
		this.Polarity.put(S, new Double(0.987));
		this.Polarity.put(T, new Double(0.784));
		this.Polarity.put(V, new Double(0.546));
		this.Polarity.put(W, new Double(0.755));
		this.Polarity.put(Y, new Double(0.665));
	}

	private void fillAntegenic()
	{
		this.Antegenic = new HashMap<String, Double>();

		this.Antegenic.put(A, new Double(1.064));
		this.Antegenic.put(C, new Double(1.412));
		this.Antegenic.put(D, new Double(0.866));
		this.Antegenic.put(E, new Double(0.851));
		this.Antegenic.put(F, new Double(1.091));
		this.Antegenic.put(G, new Double(0.874));
		this.Antegenic.put(H, new Double(1.105));
		this.Antegenic.put(I, new Double(1.152));
		this.Antegenic.put(K, new Double(0.93));
		this.Antegenic.put(L, new Double(1.25));
		this.Antegenic.put(M, new Double(0.826));
		this.Antegenic.put(N, new Double(0.776));
		this.Antegenic.put(P, new Double(1.064));
		this.Antegenic.put(Q, new Double(1.015));
		this.Antegenic.put(R, new Double(0.873));
		this.Antegenic.put(S, new Double(1.012));
		this.Antegenic.put(T, new Double(0.909));
		this.Antegenic.put(V, new Double(1.383));
		this.Antegenic.put(W, new Double(0.893));
		this.Antegenic.put(Y, new Double(1.161));

	}

	private void fillTurns()
	{
		this.Turns = new HashMap<String, Double>();

		this.Turns.put(A, new Double(0.66));
		this.Turns.put(C, new Double(1.19));
		this.Turns.put(D, new Double(1.46));
		this.Turns.put(E, new Double(0.74));
		this.Turns.put(F, new Double(0.6));
		this.Turns.put(G, new Double(1.56));
		this.Turns.put(H, new Double(0.95));
		this.Turns.put(I, new Double(0.47));
		this.Turns.put(K, new Double(1.01));
		this.Turns.put(L, new Double(0.59));
		this.Turns.put(M, new Double(0.6));
		this.Turns.put(N, new Double(1.56));
		this.Turns.put(P, new Double(1.52));
		this.Turns.put(Q, new Double(0.98));
		this.Turns.put(R, new Double(0.95));
		this.Turns.put(S, new Double(1.43));
		this.Turns.put(T, new Double(0.96));
		this.Turns.put(V, new Double(0.5));
		this.Turns.put(W, new Double(0.96));
		this.Turns.put(Y, new Double(1.14));

	}

	private void fillExposed()
	{
		this.Exposed = new HashMap<String, Double>();

		this.Exposed.put(A, new Double(15));
		this.Exposed.put(C, new Double(5));
		this.Exposed.put(D, new Double(50));
		this.Exposed.put(E, new Double(55));
		this.Exposed.put(F, new Double(10));
		this.Exposed.put(G, new Double(10));
		this.Exposed.put(H, new Double(34));
		this.Exposed.put(I, new Double(13));
		this.Exposed.put(K, new Double(85));
		this.Exposed.put(L, new Double(16));
		this.Exposed.put(M, new Double(20));
		this.Exposed.put(N, new Double(49));
		this.Exposed.put(P, new Double(45));
		this.Exposed.put(Q, new Double(56));
		this.Exposed.put(R, new Double(67));
		this.Exposed.put(S, new Double(32));
		this.Exposed.put(T, new Double(32));
		this.Exposed.put(V, new Double(14));
		this.Exposed.put(W, new Double(17));
		this.Exposed.put(Y, new Double(41));

	}

	private void fillAccessibility()
	{
		this.Accessibility = new HashMap<String, Double>();

		this.Accessibility.put(A, new Double(0.49));
		this.Accessibility.put(C, new Double(0.26));
		this.Accessibility.put(D, new Double(0.81));
		this.Accessibility.put(E, new Double(0.84));
		this.Accessibility.put(F, new Double(0.42));
		this.Accessibility.put(G, new Double(0.48));
		this.Accessibility.put(H, new Double(0.66));
		this.Accessibility.put(I, new Double(0.34));
		this.Accessibility.put(K, new Double(0.97));
		this.Accessibility.put(L, new Double(0.4));
		this.Accessibility.put(M, new Double(0.48));
		this.Accessibility.put(N, new Double(0.78));
		this.Accessibility.put(P, new Double(0.75));
		this.Accessibility.put(Q, new Double(0.84));
		this.Accessibility.put(R, new Double(0.95));
		this.Accessibility.put(S, new Double(0.65));
		this.Accessibility.put(T, new Double(0.7));
		this.Accessibility.put(V, new Double(0.36));
		this.Accessibility.put(W, new Double(0.51));
		this.Accessibility.put(Y, new Double(0.76));

	}

	private void fillFlexibility()
	{
		this.Flexibility = new HashMap<String, Double>();

		this.Flexibility.put(A, new Double(-1.27));
		this.Flexibility.put(C, new Double(-1.09));
		this.Flexibility.put(D, new Double(1.42));
		this.Flexibility.put(E, new Double(1.6));
		this.Flexibility.put(F, new Double(-2.14));
		this.Flexibility.put(G, new Double(1.86));
		this.Flexibility.put(H, new Double(-0.82));
		this.Flexibility.put(I, new Double(-2.89));
		this.Flexibility.put(K, new Double(2.88));
		this.Flexibility.put(L, new Double(-2.29));
		this.Flexibility.put(M, new Double(-1.84));
		this.Flexibility.put(N, new Double(1.77));
		this.Flexibility.put(P, new Double(0.52));
		this.Flexibility.put(Q, new Double(1.18));
		this.Flexibility.put(R, new Double(2.79));
		this.Flexibility.put(S, new Double(3));
		this.Flexibility.put(T, new Double(1.18));
		this.Flexibility.put(V, new Double(-1.75));
		this.Flexibility.put(W, new Double(-3.78));
		this.Flexibility.put(Y, new Double(-3.3));

	}

	private void fillHydrophilicity()
	{
		this.Hydrophilicity = new HashMap<String, Double>();

		this.Hydrophilicity.put(A, new Double(2.10));
		this.Hydrophilicity.put(C, new Double(1.40));
		this.Hydrophilicity.put(D, new Double(10.00));
		this.Hydrophilicity.put(E, new Double(7.80));
		this.Hydrophilicity.put(F, new Double(-9.20));
		this.Hydrophilicity.put(G, new Double(5.70));
		this.Hydrophilicity.put(H, new Double(2.10));
		this.Hydrophilicity.put(I, new Double(-8.00));
		this.Hydrophilicity.put(K, new Double(5.70));
		this.Hydrophilicity.put(L, new Double(-9.20));
		this.Hydrophilicity.put(M, new Double(-4.20));
		this.Hydrophilicity.put(N, new Double(7.00));
		this.Hydrophilicity.put(P, new Double(2.10));
		this.Hydrophilicity.put(Q, new Double(6.00));
		this.Hydrophilicity.put(R, new Double(4.20));
		this.Hydrophilicity.put(S, new Double(6.50));
		this.Hydrophilicity.put(T, new Double(5.20));
		this.Hydrophilicity.put(V, new Double(-3.7));
		this.Hydrophilicity.put(W, new Double(-10.0));
		this.Hydrophilicity.put(Y, new Double(-1.9));

	}

	private void fillHydrophopicity()
	{
		this.Hydrophopicity = new HashMap<String, Double>();

		this.Hydrophopicity.put(A, new Double(0.626));
		this.Hydrophopicity.put(C, new Double(0.680));
		this.Hydrophopicity.put(D, new Double(0.028));
		this.Hydrophopicity.put(E, new Double(0.043));
		this.Hydrophopicity.put(F, new Double(1.00));
		this.Hydrophopicity.put(G, new Double(0.501));
		this.Hydrophopicity.put(H, new Double(0.165));
		this.Hydrophopicity.put(I, new Double(0.943));
		this.Hydrophopicity.put(K, new Double(0.283));
		this.Hydrophopicity.put(L, new Double(0.943));
		this.Hydrophopicity.put(M, new Double(0.738));
		this.Hydrophopicity.put(N, new Double(0.236));
		this.Hydrophopicity.put(P, new Double(0.711));
		this.Hydrophopicity.put(Q, new Double(0.251));
		this.Hydrophopicity.put(R, new Double(0.000));
		this.Hydrophopicity.put(S, new Double(0.359));
		this.Hydrophopicity.put(T, new Double(0.450));
		this.Hydrophopicity.put(V, new Double(0.825));
		this.Hydrophopicity.put(W, new Double(0.878));
		this.Hydrophopicity.put(Y, new Double(0.880));
	}

}
